package com.xiaoka.ins.corp.api.config;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.oxm.jaxb.Jaxb2Marshaller;

import com.xiaoka.ins.corp.api.aics.proxy.Bill99PayProxy;
import com.xiaoka.ins.corp.api.aics.proxy.CheckBizProxy;
import com.xiaoka.ins.corp.api.aics.proxy.GenPolicyProxy;
import com.xiaoka.ins.corp.api.aics.proxy.PolicyStatusProxy;
import com.xiaoka.ins.corp.api.aics.proxy.QuoteBizProxy;
import com.xiaoka.ins.corp.api.aics.proxy.QuoteNewBizProxy;
import com.xiaoka.ins.corp.api.aics.proxy.QuoteTrafficProxy;
import com.xiaoka.ins.corp.api.aics.proxy.VehicleTypeProxy;

@Configuration
public class WsProxyConfig{
	
	@Resource
	private AicsConfig aicsConfig;
	
	@Autowired
	private Jaxb2Marshaller marshaller;
	
	@Bean
	public VehicleTypeProxy getVehicleTypeClient(Jaxb2Marshaller marshaller) {
		String sevUrl = "http://" + aicsConfig.getServiceUrl() + "/";
		VehicleTypeProxy client = new VehicleTypeProxy();
		client.setDefaultUri(sevUrl + "queryVehicleTypesService");
		client.setMarshaller(marshaller);
		client.setUnmarshaller(marshaller);
		return client;
	}
	
	@Bean
	public QuoteBizProxy getQuoteBizClient(Jaxb2Marshaller marshaller) {
		String sevUrl = "http://" + aicsConfig.getServiceUrl() + "/";
		QuoteBizProxy client = new QuoteBizProxy();
		client.setDefaultUri(sevUrl + "queryVehicleInsuranceQuotationCiService");
		client.setMarshaller(marshaller);
		client.setUnmarshaller(marshaller);
		return client;
	}
	
	@Bean
	public QuoteNewBizProxy getQuoteNewBizClient(Jaxb2Marshaller marshaller) {
		String sevUrl = "http://" + aicsConfig.getServiceUrl() + "/";
		QuoteNewBizProxy client = new QuoteNewBizProxy();
		client.setDefaultUri(sevUrl + "thirdPartyQuotationService");
		client.setMarshaller(marshaller);
		client.setUnmarshaller(marshaller);
		return client;
	}
	
	@Bean
	public CheckBizProxy getCheckBizClient(Jaxb2Marshaller marshaller) {
		String sevUrl = "http://" + aicsConfig.getServiceUrl() + "/";
		CheckBizProxy client = new CheckBizProxy();
		client.setDefaultUri(sevUrl + "underwriteVehicleInsurancePolicyCiService");
		client.setMarshaller(marshaller);
		client.setUnmarshaller(marshaller);
		return client;
	}
	
	@Bean
	public QuoteTrafficProxy getQuoteTrafficClient(Jaxb2Marshaller marshaller) {
		String sevUrl = "http://" + aicsConfig.getServiceUrl() + "/";
		QuoteTrafficProxy client = new QuoteTrafficProxy();
		client.setDefaultUri(sevUrl + "queryVehicleInsuranceQuotationSaliService");
		client.setMarshaller(marshaller);
		client.setUnmarshaller(marshaller);
		return client;
	}
	
	@Bean
	public GenPolicyProxy getGenPolicyClient(Jaxb2Marshaller marshaller) {
		String sevUrl = "http://" + aicsConfig.getServiceUrl() + "/";
		GenPolicyProxy client = new GenPolicyProxy();
		client.setDefaultUri(sevUrl + "confirmVehicleInsuranceApplyService");
		client.setMarshaller(marshaller);
		client.setUnmarshaller(marshaller);
		return client;
	}
	
	@Bean
	public PolicyStatusProxy getPoilcyStatusClient(Jaxb2Marshaller marshaller) {
		String sevUrl = "http://" + aicsConfig.getServiceUrl() + "/";
		PolicyStatusProxy client = new PolicyStatusProxy();
		client.setDefaultUri(sevUrl + "thirdPolicyStatusQueryService");
		client.setMarshaller(marshaller);
		client.setUnmarshaller(marshaller);
		return client;
	}
	
	@Bean
	public Bill99PayProxy getBill99PayClient(Jaxb2Marshaller marshaller) {
		String sevUrl = "http://" + aicsConfig.getServiceUrl() + "/";
		Bill99PayProxy client = new Bill99PayProxy();
		client.setDefaultUri(sevUrl + "thirdBill99PayService");
		client.setMarshaller(marshaller);
		client.setUnmarshaller(marshaller);
		return client;
	}
}